﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="RawMaterialOrder.aspx.cs" Inherits="XYZ_Inventory.RawMaterialOrder1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="Styles/GridView.css" rel="stylesheet" type="text/css"/>
    <link href="Styles/ValidationSummary.css" rel="stylesheet" type="text/css"/>
    <link href="Styles/CustomTable.css" rel="stylesheet" type="text/css"/>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <fieldset style="margin: 0.5em; padding: 0.5em;">
        <legend>Reorder level raw materials</legend>
        <asp:GridView ID="GridView1" CssClass="gridView" runat="server" Style="float: left;"
                      AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellPadding="4"
                      ForeColor="#333333" GridLines="None" DataKeyNames="RawMaterialID" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
            <AlternatingRowStyle BackColor="White" ForeColor="#284775"/>
            <Columns>
                <asp:BoundField DataField="RawMaterialID" HeaderText="Material ID">
                    <ItemStyle HorizontalAlign="Right"/>
                </asp:BoundField>
                <asp:BoundField DataField="RawMaterialName" HeaderText="Material Name"/>
                <asp:BoundField DataField="RawMaterialType" HeaderText="Material Type"/>
                <asp:TemplateField HeaderText="Description">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("Description").ToString().Replace(Environment.NewLine, "<br/>") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="ReorderLevel" HeaderText="Reorder Level">
                    <ItemStyle HorizontalAlign="Right"/>
                </asp:BoundField>
                <asp:BoundField DataField="Stock" HeaderText="Stock">
                    <ItemStyle HorizontalAlign="Right"/>
                </asp:BoundField>
                <asp:CommandField HeaderText="Action" SelectText="Make Order" ShowSelectButton="True"/>
            </Columns>
            <EditRowStyle BackColor="#999999"/>
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center"/>
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333"/>
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333"/>
            <SortedAscendingCellStyle BackColor="#E9E7E2"/>
            <SortedAscendingHeaderStyle BackColor="#506C8C"/>
            <SortedDescendingCellStyle BackColor="#FFFDF8"/>
            <SortedDescendingHeaderStyle BackColor="#6F8DAE"/>
        </asp:GridView>
        <table class="table" id="tblMakeOrder" style="float: left; padding-left: 1em;" runat="server">
            <tr>
                <th colspan="2">
                    Make Order
                </th>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="Label1" runat="server" Text="Product Name"></asp:Label>
                </td>
                <td>
                    <asp:DropDownList ID="ddlProduct" runat="server" Enabled="False" DataSourceID="RawMaterialSource"
                                      DataTextField="RawMaterialName" DataValueField="RawMaterialID">
                    </asp:DropDownList>
                    <asp:EntityDataSource ID="RawMaterialSource" runat="server" ConnectionString="name=XYZDBContext"
                                          DefaultContainerName="XYZDBContext" EnableFlattening="False" EntitySetName="RawMaterialInventories"
                                          Select="it.[RawMaterialID], it.[RawMaterialName]">
                    </asp:EntityDataSource>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="Label4" runat="server" Text="Quantity"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtQty" runat="server" min="1" Width="75" TextMode="Number"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtQty"
                                                ErrorMessage="Product quantity is required." Text="*" ForeColor="Red" Display="Dynamic"
                                                ValidationGroup="Order">
                    </asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="Label5" runat="server" Text="Supplier"></asp:Label>
                </td>
                <td>
                    <asp:DropDownList ID="ddlSupplier" runat="server" DataSourceID="SupplierSource" DataTextField="Name"
                                      DataValueField="ID">
                    </asp:DropDownList>
                    <asp:EntityDataSource ID="SupplierSource" runat="server" ConnectionString="name=XYZDBContext"
                                          DefaultContainerName="XYZDBContext" EnableFlattening="False" EntitySetName="Suppliers1"
                                          EntityTypeFilter="Supplier" Select="it.[ID], it.[Name]">
                    </asp:EntityDataSource>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="background-color: #E2DED6; color: #284775;">
                    <asp:Button ID="btnAdd" runat="server" Text="Create Order" ValidationGroup="Order"
                                OnClick="btnAdd_Click"/>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="background-color: #E2DED6; color: #284775;">
                    <asp:ValidationSummary ID="ValidationSummary1" CssClass="validationSummary" HeaderText="<b>Please fix following error(s):</b>"
                                           ValidationGroup="Order" ForeColor="Red" runat="server"/>
                    <asp:Label ID="lblStatus" runat="server" Text=""></asp:Label>
                </td>
            </tr>
        </table>
    </fieldset>
    <br/>
    <br/>
    <a href="RawMaterialOrderHistory.aspx">View past raw material orders</a>
</asp:Content>
